temphum13 2.2.1
temphum13.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2026 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
31// ----------------------------------------------------------------------------
32
33#ifndef TEMPHUM13_H
34#define TEMPHUM13_H
35
40#ifdef PREINIT_SUPPORTED
41#include "preinit.h"
42#endif
43
44#ifdef MikroCCoreVersion
45 #if MikroCCoreVersion >= 1
46 #include "delays.h"
47 #endif
48#endif
49
50#include "drv_digital_out.h"
51#include "drv_digital_in.h"
52#include "drv_i2c_master.h"
53
54// -------------------------------------------------------------- PUBLIC MACROS
59
64#define TEMPHUM13_MAP_MIKROBUS( cfg, mikrobus ) \
65 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
66 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
67
68
73#define TEMPHUM13_RETVAL uint8_t
74
75#define TEMPHUM13_OK 0x00
76#define TEMPHUM13_INIT_ERROR 0xFF
78
83#define TEMPHUM13_DEVICE_ADDRESS 0x40
85
90#define TEMPHUM13_CMD_TRIG_TEMP_MEAS_HOLD 0xE3
91#define TEMPHUM13_CMD_TRIG_HUMI_MEAS_HOLD 0xE5
92#define TEMPHUM13_CMD_TRIG_TEMP_MEAS_NOHOLD 0xF3
93#define TEMPHUM13_CMD_TRIG_HUMI_MEAS_NOHOLD 0xF5
94#define TEMPHUM13_CMD_WRITE_USER_REG 0xE6
95#define TEMPHUM13_CMD_READ_USER_REG 0xE7
96#define TEMPHUM13_CMD_SOFT_RESET 0xFE
98
99
104#define TEMPHUM13_HEATER_ENABLE 0x01
105#define TEMPHUM13_HEATER_DISABLE 0x00
107
112#define TEMPHUM13_RESOLUTION_8 0x01
113#define TEMPHUM13_RESOLUTION_10 0x80
114#define TEMPHUM13_RESOLUTION_11 0x81
115#define TEMPHUM13_RESOLUTION_12 0x00
117
122#define TEMPHUM13_OTP_DISABLE 0x01
123#define TEMPHUM13_OTP_ENABLE 0x00
125
126 // End group macro
128// --------------------------------------------------------------- PUBLIC TYPES
133
137typedef struct
138{
139 // Modules
140
141 i2c_master_t i2c;
142
143 // ctx variable
144
146
148
152typedef struct
153{
154 // Communication gpio pins
155
156 pin_name_t scl;
157 pin_name_t sda;
158
159 // static variable
160
161 uint32_t i2c_speed;
162 uint8_t i2c_address;
163
165 // End types group // End variable group
168// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
169
174
175#ifdef __cplusplus
176extern "C"{
177#endif
178
188
198
208
219void temphum13_generic_write ( temphum13_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
220
231void temphum13_generic_read ( temphum13_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
232
243
254
265
274void temphum13_set_user_register ( temphum13_t *ctx, uint8_t register_content );
275
284
300uint8_t temphum13_enable_heater ( temphum13_t *ctx, uint8_t enable_heater );
301
318uint8_t temphum13_change_resolution ( temphum13_t *ctx, uint8_t meas_res );
319
335uint8_t temphum13_disable_otp_reload ( temphum13_t *ctx, uint8_t disable_otp_rel );
336
337#ifdef __cplusplus
338}
339#endif
340#endif // _TEMPHUM13_H_
341 // End public_function group
344
345// ------------------------------------------------------------------------- END
#define TEMPHUM13_RETVAL
Definition temphum13.h:73
void temphum13_generic_read(temphum13_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t temphum13_change_resolution(temphum13_t *ctx, uint8_t meas_res)
Change measurement resolution.
float temphum13_get_temperature(temphum13_t *ctx)
Get temperature value.
void temphum13_set_user_register(temphum13_t *ctx, uint8_t register_content)
Set user register.
uint8_t temphum13_disable_otp_reload(temphum13_t *ctx, uint8_t disable_otp_rel)
Disable OTP.
void temphum13_default_cfg(temphum13_t *ctx)
Click Default Configuration function.
float temphum13_get_humidity(temphum13_t *ctx)
Get humidity value.
void temphum13_cfg_setup(temphum13_cfg_t *cfg)
Config Object Initialization function.
uint8_t temphum13_enable_heater(temphum13_t *ctx, uint8_t enable_heater)
Enable heater.
TEMPHUM13_RETVAL temphum13_init(temphum13_t *ctx, temphum13_cfg_t *cfg)
Initialization function.
void temphum13_soft_reset(temphum13_t *ctx)
Software reset.
void temphum13_generic_write(temphum13_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t temphum13_get_user_register(temphum13_t *ctx)
Get user register value.
Click configuration structure definition.
Definition temphum13.h:153
uint32_t i2c_speed
Definition temphum13.h:161
pin_name_t scl
Definition temphum13.h:156
pin_name_t sda
Definition temphum13.h:157
uint8_t i2c_address
Definition temphum13.h:162
Click ctx object definition.
Definition temphum13.h:138
i2c_master_t i2c
Definition temphum13.h:141
uint8_t slave_address
Definition temphum13.h:145